﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ObjectModel.PowerPoint
{
    /// <summary>
    /// A class serializable class that caches a live reference to the underlying
    /// PowerPoint object.
    /// </summary>
    public class CachedObject : ResolvableObject
    {
        object mObject;

        public CachedObject() { } // Parameterless constructor needed for deserialization.

        public CachedObject(object o)
        {
            StoredObject = ResolvableObjectFactory.CreateObject(o);
            mObject = o;
        }

        public virtual ResolvableObject StoredObject { get; set; }

        public override object Resolve()
        {
            if (mObject == null)
                mObject = StoredObject.Resolve();

            return mObject;
        }
    }
}
